"""泛型"""


from typing import TypeVar, Generic, List

T = TypeVar("T", int, float)


class Stack(Generic[T]):
    """
    The Stack class can be used to represent a stack of any type: Stack[int],
    Stack[Tuple[int, str]], etc
    """
    def __init__(self) -> None:
        self.items: List[T] = []

    def push(self, item: T) -> None:
        self.items.append(item)

    def pop(self) -> T:
        return self.items.pop()

    def empty(self) -> bool:
        return not self.items


# Construct an empty Stack[int] Instance
stack = Stack[int]()
stack.push(2)
stack.pop()
stack.push(2)
stack.push("abc")

# stack = Stack[str]()
# stack.push("1111")
# stack.pop()
# stack.push("alfoson")
# print(stack.items)
"""
我的个人理解：
    T 表示任意的类型
    stack[int]表示Stack只能存储int类型，后面
"""


class MyInt(Generic[T]):
    def __init__(self):
        self.item: List[T] = []

    def add(self, value: T):
        self.item.append(value)

    def remove(self, value: [T]):
        self.item.remove(value)






